lastCase <- function(df){
  df[, keep := as.Date(bail_date) == max(as.Date(bail_date)), by = c("uniqueid")]
  df <- df[keep == 1]
  return(df)
}
